#coding=utf-8
#author：zhujingyuan

from Common.oracleExcute import OracelExcute
from Config.config import environmentData
from Common.mongodbExcute import MongodbExcute
# from Params.CommonParas import mobile
import  Config.config as cf
mobile='15067437090'

# cf.InitEnvironmentData(cf.TestAddress,env='TestEnv')
#oracle数据库查询
oracle=OracelExcute(user=environmentData['user'],ip=environmentData['ip'],port=environmentData['port'],servicename=environmentData['servicename'],password=environmentData['password'])
#老卡HH查询（用于老卡升级为VL卡）
oldcardid=oracle.execQueryOne("select c.cardid from cm_card c where c.SITECODE='HH' and c.status='正常' and c.CARDTYPEID in (50,42,61,65,43)")
#老卡II#查询（用于绑定品牌卡）
oldcardid2=oracle.execQueryOne("select c.cardid from cm_card c where c.SITECODE='II' and c.status='正常' and c.CARDTYPEID in (50,42,61,65,43)")
oldcutomerid2=oracle.execQueryOne("select c.customerid from cm_card c where c.cardid='"+str(oldcardid2)+"'")

oldmobile2=oracle.execQueryOne("select a.mobilephone from cm_customer a where a.customerid='"+str(oldcutomerid2)+"'")
customerid=oracle.execQueryOne("select c.customerid from cm_card c where c.cardid='"+environmentData['CardId']+"'")

#mongodb查询
mongo=MongodbExcute(ip=environmentData['mongoip'],port=environmentData['mongoport'],db=environmentData['mongodb'])

promotionid=mongo.findlimitExcute(col='List_Goods',num=1)['PromotionsId']
sku=mongo.findlimitExcute(col='List_Goods',num=1,query={'PromotionsId':promotionid})['ProductId']
orderSN=mongo.findlimitExcute(col='Order',num=1,query={'UserPhone': mobile})['OrderSN']

# print(promotionid)
# print(type(promotionid))
# print(sku)
# print(type(sku))
# print(type(oldcardid))
# print(oldcardid2)



#
# print(oldcardid2)
# print(type(oldcardid2))